<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2015-11-2
 * Time: 12:38
 */
require_once 'C:\xampp\htdocs\laravel\PHPExcel.php';

try {
    $inputFileName = 'test.xlsx';

    $coltype = array(0 => 'string', 1 => 'number', 2 => 'number', 3 => 'date', 4 => 'time');

    /**  Identify the type of $inputFileName  **/
    $inputFileType = PHPExcel_IOFactory::identify($inputFileName);
    /**  Create a new Reader of the type that has been identified  **/
    $objReader = PHPExcel_IOFactory::createReader($inputFileType);
    /**  Load only the rows and columns that match our filter to PHPExcel  **/
    $objPHPExcel = $objReader->load($inputFileName);
    $objWorksheet = $objPHPExcel->getActiveSheet();
    $count = $objWorksheet->getHighestRow();


    echo '=====================================' . "\n";
    for ($row = 1; $row <= $count; $row++) {
        echo '------------------------------------' . "\n";
        for ($col = 0; $col < count($coltype); $col++) {
           /* if ($coltype[$col] == 'string') {
                $txt = iconv('UTF-8', 'GBK', $objWorksheet->getCellByColumnAndRow($col, $row)->getValue());
                echo $txt . '  ';
            } elseif ($coltype[$col] == 'date')
            {
                $txt=gmdate('Y/m/d',PHPExcel_Shared_Date::ExcelToPHP($objWorksheet->getCellByColumnAndRow($col, $row)->getValue()));
                echo $txt . '  ';

            }
            elseif($coltype[$col] == 'time')
            {
                $txt=gmdate('H:i:s',PHPExcel_Shared_Date::ExcelToPHP($objWorksheet->getCellByColumnAndRow($col, $row)->getValue()));
                echo $txt . '  ';

            }else*/
                echo iconv('UTF-8', 'GBK', $objWorksheet->getCellByColumnAndRow($col, $row)->getFormattedValue()) . '  ';
        }
        echo "\n";

        echo '------------------------------------' . "\n";
    }

    echo '=====================================' . "\n";


    echo 'Successful!';
} catch (Exception $e) {
    echo 'Failed!:' . $e->getMessage();
}